package mochizuki.weixin.controller;

import com.jfinal.core.Controller;
import com.jfinal.plugin.activerecord.Page;
import mochizuki.weixin.model.MerchandiseModel;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by yzh004 on 2016/6/25.
 *
 */
public class MallController  extends Controller{
    public void index(){


        Page<MerchandiseModel> page= new Page<>(makelist(),1,10,1,5);
        setAttr("listpage",page);
        String userid=getPara("openid");
        setAttr("userinfo",userid);
        render("/mall.ftl");
    }

    private  List<MerchandiseModel> makelist(){
        List<MerchandiseModel> list=new ArrayList<>();
        for (int i=0;i<5;i++){
            MerchandiseModel row=new MerchandiseModel();
            row.setId(1+i);
            row.setName("商品"+String.valueOf(i));
            row.setSpecifications("规格"+String.valueOf(i));
            row.setPrice(new BigDecimal(7+i));
            list.add(row);
        }
        return list;
    }
}
